home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
MPW_TOOL
/
TOOLS
/
TOOLS_WI
/
ICON_8
/
MEMMON_F
/
MINPUT.C
< prev
next >
Wrap
Text File
|
1990-03-02
|
2KB
|
101 lines
/*
* minput.c: input routines.
*/
#include <ctype.h>
#include "memmon.h"
static word previous[256]; /* previous length, indexed by input char */
/*
* getcmd(&addr, &len) - get next command, returning key character.
*/
int getcmd(addr, len)
word *addr, *len;
{
int c;
word n;
c = getc(ifile);
while (isspace(c))
c = getc(ifile);
if (c == EOF)
return 0;
if (isdigit(c)) {
n = c - '0';
while (isdigit(c = getc(ifile)))
n = 10 * n + c - '0';
if (c == '+') {
c = getcmd(addr, len);
*addr = n;
}
else {
*addr = -1;
*len = n;
previous[c] = n;
}
}
else {
*addr = -1;
*len = previous[c];
}
return c;
}
/*
* getshow() - get the color for an mmshow() command.
*
* An mmshow command is followed by two characters "ct"; c is the color
* character passed to mmshow(), and t is the type of the item.
*/
word getshow()
{
int c, t;
c = getc(ifile);
t = getc(ifile);
switch (c) {
case 'b': return Unmarked + C_Black;
case 'g': return Unmarked + C_Grey;
case 'h': return Unmarked + C_Blink;
case 'r': return Unmarked + blkcolor[t];
case 'w': return Unmarked + C_White;
default: return Unmarked + C_Blink;
}
}
/*
* getregion() - get region information (base, used, length for one region).
*/
novalue getregion(rgn)
struct region *rgn;
{
word addr;
getcmd(&addr, &rgn->base);
getcmd(&addr, &rgn->used);
getcmd(&addr, &rgn->length);
}
/*
* rsync() - region synchronization (sanity check).
*
* Rsync reads region information and compares it with what we already know.
* A discrepancy indicates a program bug or corrupted data file.
*/
novalue rsync(rgn, label)
struct region *rgn;
char *label;
{
struct region r;
getregion(&r);
if (r.base != rgn->base || r.used != rgn->used || r.length != rgn->length) {
fprintf(stderr, "%s internal error: out of sync: %s region\n",
progname, label);
fprintf(stderr, "expected %ld:%ld/%ld, got %ld:%ld/%ld\n",
rgn->base, rgn->used, rgn->length, r.base, r.used, r.length);
exit(ErrorExit);
}
}